package com.franklin.ideaplugin.maphelper.col.operation.impl.map;

import com.franklin.ideaplugin.maphelper.col.method.IColInsertMethod;
import com.franklin.ideaplugin.maphelper.col.operation.IColReadWriteOperation;
import com.franklin.ideaplugin.maphelper.col.method.IColQueryMethod;
import com.franklin.ideaplugin.maphelper.col.method.impl.ColInsertMethodImpl;
import com.franklin.ideaplugin.maphelper.col.method.impl.DefaultColQueryMethod;
import com.google.common.collect.Sets;

import java.util.Map;
import java.util.Set;

/**
 * @author Ye Junhui
 * @since 2024/3/11
 */
public class MapReadWriteOperation implements IColReadWriteOperation {

    @Override
    public String getClassQualifiedName() {
        return Map.class.getName();
    }

    @Override
    public Set<IColInsertMethod> getInsertMethods() {
        return Sets.newHashSet(
                new ColInsertMethodImpl("put",2,1),
                new ColInsertMethodImpl("putIfAbsent",2,1),
                new ColInsertMethodImpl("replace",3,2),
                new ColInsertMethodImpl("replace",2,1)
        );
    }

    @Override
    public Set<IColInsertMethod> getInsertAllMethods() {
        return Sets.newHashSet(
                new ColInsertMethodImpl("putAll",1,0)
        );
    }

    @Override
    public Set<IColQueryMethod> getQueryMethods() {
        return Sets.newHashSet(
                new DefaultColQueryMethod("get", 1, 0),
                new DefaultColQueryMethod("remove", 1, 0),
                new DefaultColQueryMethod("replace", 2, 0),
                new DefaultColQueryMethod("getOrDefault", 2, 0)
        );
    }
}
